"""
字典的常用操作
- 字典[Key]=Value
- pop
- clear
- keys
- len
"""
my_dict = {"黄子":99,"凯凯":87,"韬韬":100}

# 1.新增元素：字典[Key]=Value
my_dict["阿蒲"] = 90
print(f"新增元素后的字典是：{my_dict}")

# 2.更新元素：字典[Key]=Value，Key已经存在的话，会将Value进行更新
my_dict["阿蒲"] = 98
print(f"对已有key更新元素后的字典是：{my_dict}")

# 3.删除元素：字典.pop(Key)
value = my_dict.pop("黄子")
print(f"删除元素后的字典为：{my_dict}，黄子的考试分数为：{value}")

# 4.清空字典：字典.clear()
my_dict.clear()
print(f"清空后的字典为：{my_dict}")

# 5.获取全部的key：字典.keys()
my_dict = {"黄子":99,"凯凯":87,"韬韬":100}
keys = my_dict.keys()
print(f"获取到字典全部的key为：{keys}")

# 6.遍历字典
# 6.1 通过获取到全部的key来遍历
keys = my_dict.keys()
for key in keys:
    value = my_dict[key]
    print(f"字典中的[key:value]为：[{key}:{value}]")
# 6.2 直接对字典进行for循环遍历,每一次循环都是直接得到key
for key in my_dict:
    value = my_dict[key]
    print(f"字典中的[key:value]为：[{key}:{value}]")

# 7.统计字典的元素数量
count = len(my_dict)
print(f"字典的元素数量为：{count}")

# 小练习：升职加薪
emp_dict = {
    "阿蒲":{"部门":"科技部","工资":3000,"级别":1},
    "韬韬":{"部门":"市场部","工资":5000,"级别":2},
    "恩齐":{"部门":"市场部","工资":7000,"级别":3},
    "小何":{"部门":"科技部","工资":4000,"级别":1},
    "小齐":{"部门":"市场部","工资":6000,"级别":2}
}
print(f"全体员工当前信息如下：{emp_dict}")
for key1 in emp_dict:
        if emp_dict[key1]["级别"] == 1:
            emp_dict[key1]["级别"]+=1
            emp_dict[key1]["工资"]+=1000
print(f"全体员工级别为1的员工完成升职加薪操作后：{emp_dict}")